import 'package:taonile/generated/json/base/json_field.dart';
import 'package:taonile/generated/json/coin_list_entity.g.dart';
import 'dart:convert';

@JsonSerializable()
class CoinListEntity {
  late int code = 0;
  late String msg;
  late List<CoinListData> data = [];

  CoinListEntity();

  factory CoinListEntity.fromJson(Map<String, dynamic> json) => $CoinListEntityFromJson(json);

  Map<String, dynamic> toJson() => $CoinListEntityToJson(this);

  @override
  String toString() {
    return jsonEncode(this);
  }
}

@JsonSerializable()
class CoinListData {
  late String id;
  late String symbol;
  late String name;
  late String image;
  @JSONField(name: "current_price")
  late String currentPrice;
  @JSONField(name: "market_cap")
  late String marketCap;
  @JSONField(name: "market_cap_rank")
  late String marketCapRank;
  @JSONField(name: "fully_diluted_valuation")
  late String fullyDilutedValuation;
  @JSONField(name: "total_volume")
  late String totalVolume;
  @JSONField(name: "high_24h")
  late String high24h;
  @JSONField(name: "low_24h")
  late String low24h;
  @JSONField(name: "price_change_24h")
  late String priceChange24h;
  @JSONField(name: "price_change_percentage_24h")
  late String priceChangePercentage24h;
  @JSONField(name: "market_cap_change_24h")
  late String marketCapChange24h;
  @JSONField(name: "market_cap_change_percentage_24h")
  late String marketCapChangePercentage24h;
  @JSONField(name: "circulating_supply")
  late String circulatingSupply;
  @JSONField(name: "total_supply")
  late String totalSupply;
  @JSONField(name: "max_supply")
  late String maxSupply;
  late String ath;
  @JSONField(name: "ath_change_percentage")
  late String athChangePercentage;
  @JSONField(name: "ath_date")
  late String athDate;
  late String atl;
  @JSONField(name: "atl_change_percentage")
  late String atlChangePercentage;
  @JSONField(name: "atl_date")
  late String atlDate;
  late String roi;
  @JSONField(name: "last_updated")
  late String lastUpdated;

  CoinListData();

  factory CoinListData.fromJson(Map<String, dynamic> json) => $CoinListDataFromJson(json);

  Map<String, dynamic> toJson() => $CoinListDataToJson(this);

  @override
  String toString() {
    return jsonEncode(this);
  }
}
